﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using SlimDX;

namespace Gype.UI
{
    public enum ArcQuadrant
    {
        BottomRight = 0,
        BottomLeft = 1,
        TopLeft = 2,
        TopRight = 3, 

        Upper = 4,
        Lower = 5
    }

    public abstract class Rendertarget
    {
        public abstract void BeginUI();
        public abstract void EndUI();
        public abstract void FillTriangle(Vector2 p1, Vector2 p2, Vector2 p3, Brush color);
        public abstract void FillRectangle(Vector2 position, Vector2 size, Brush color);
        public abstract void DrawRectangle(Vector2 position, Vector2 size, Brush color, float strokeWidth = 1, RectangleFillMask fillMask = RectangleFillMask.All);
        public abstract void FillRoundedRectangle(Vector2 position, Vector2 size, float horizontalRadius, float verticalRadius, Brush color);
        public abstract void DrawRoundedRectangle(Vector2 position, Vector2 size, float horizontalRadius, float verticalRadius, Brush color, float strokeWidth = 1);
        public abstract void FillEllipse(Ellipse ellipse, Color4 color);
        public abstract void DrawEllipse(Ellipse ellipse, Color4 color, float stroke);
        public abstract void DrawArc(Ellipse ellipse, Color4 color, float stroke, float angleStart, float angleEnd);
        public abstract void DrawEllipseFourth(Ellipse ellipse, Color4 color, float stroke, ArcQuadrant quadrant);
        public abstract void DrawEllipseHalf(Ellipse ellipse, Color4 color, float stroke, ArcQuadrant quadrant);
        public abstract void DrawImage(Image image, System.Drawing.RectangleF destRectangle);
        public abstract void DrawImage(Image image, System.Drawing.RectangleF destRectangle, System.Drawing.RectangleF srcRectangle);
        public abstract void PushClipArea(RectangleF area);
        public abstract void PopClipArea();
        public abstract void SetClipEnabled(bool enabled);

        public abstract SpriteFont CreateFont(string familyName, int pixelSize);

        public LinearMatrix Transform { get; set; }
        public Vector2 Viewport { get; protected set; }

        internal abstract Image CreateImage(System.Drawing.Bitmap bmp);
        internal abstract Brush CreateSolidColorBrush(Color4 color);
        internal abstract Brush CreateLinearGradient(LinearGradientDescription gradientDescription);
        internal abstract Brush CreateRadialGradient(RadialGradientDescription gDesc);
        internal abstract System.Drawing.Size GetMaximumTextureSize();

        public static Rendertarget CreateTarget(SlimDX.Direct3D9.Device dev9)
        {
            return new D3D9.Rendertarget9(dev9, dev9.Viewport);
        }
    }
}
